/////////////////////////////////////////////     File     //////////////////////////////////////////////////
// Author: James Chen
// Filename: LaserRangefinder.h
// Created: Sunday, August 15, 2010 9:10:38 AM
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "CUtilities.h"
#include "Vertex.h"

/////////////////////////////////////////////     Class     /////////////////////////////////////////////////
// Name: CLaserRangefinder
// Author: James Chen
// Created: Sunday, August 15, 2010 9:10:39 AM
//
// Purpose: Ranges the targets that one cannot estimate
//
// Revisions: 
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
class CLaserRangefinder
{
	////////////////////// Singleton Implementation Begins //////////////////////
private:

	D3DXMATRIX m_matRotation;

	D3DXVECTOR3 m_vecCurrentPosition;
	D3DXVECTOR3 m_vecTargetPosition;

	D3DXVECTOR3 m_vecMidpoint;

	double m_dDistance;
	double m_dMidDistance;

	float m_fXRot;
	float m_fYRot;


	DWORD mNumVertices;
	DWORD mNumFaces;

	ID3D10Device* md3dDevice;
	ID3D10Buffer* mVB;
	ID3D10Buffer* mIB;


	CLaserRangefinder(void);
	CLaserRangefinder(const CLaserRangefinder&);
	CLaserRangefinder& operator =(const CLaserRangefinder&);
	static CLaserRangefinder *m_pInstance;

public:

	virtual ~CLaserRangefinder(void);
	static CLaserRangefinder *GetInstance(void);
	static void DeleteInstance(void);
	/////////////////////// Singleton Implementation Ends ///////////////////////

	void init(ID3D10Device* device, D3DXCOLOR color);
	void draw();

	double GetDistance(D3DXVECTOR3 currpos, D3DXVECTOR3 tarpos)
	{
		m_vecCurrentPosition = currpos;
		m_vecTargetPosition = tarpos;

		this->m_dDistance = CMath::GetInstance()->DistanceTrue(m_vecCurrentPosition, m_vecTargetPosition);

		this->m_dMidDistance = this->m_dDistance / 2;

		return this->m_dDistance;
	}

	void CalculateLaser();

};